package com.mark.search.dto;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;

/**
 * <p>
 * 枚举
 * </p>
 *
 * @author : mark
 * @since : 2021/10/12 16:47
 */
public enum OrderStateVOEnum {

    /**
     * 待审核
     */
    待审核(1, "待审核", "待审核"),

    /**
     * 审核通过
     */
    审核通过(2, "审核通过", "审核通过"),

    /**
     * 审核拒绝
     */
    审核拒绝(3, "审核拒绝", "审核拒绝"),

    /**
     * 审核拒绝
     */
    审核结束(4, "审核结束", "审核结束"),
    ;


    Integer code;
    String value;
    String desc;

    OrderStateVOEnum(Integer code, String value, String desc) {
        this.code = code;
        this.value = value;
        this.desc = desc;
    }

    public static OrderStateVOEnum getByCode(Integer code) {
        Optional<OrderStateVOEnum> optional = Arrays.stream(OrderStateVOEnum.values())
                .filter(item -> Objects.equals(item.getCode(), code)).findFirst();
        return optional.orElse(null);
    }

    public static String getName(Integer code) {
        for (OrderStateVOEnum s : OrderStateVOEnum.values()) {
            if (s.getCode().equals(code)) {
                return s.getValue();
            }
        }

        return null;
    }

    public Integer getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }
}
